<?php
    include 'conn.php';//引入外部文件

    //接受前端传来的数据
    $name = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
    $password = isset($_REQUEST['password']) ? $_REQUEST['password'] : '';
    $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';

    //查询语句
    $sql = "INSERT INTO userinf(name,psw,email) VALUES('$name','$password','$email')";
    
    //执行语句
    $res = $conn->query($sql);//insert语句执行后得到的是布尔值

    //var_dump($res);
    if($res) {
        //true：保存成功
        echo '0';
    }else{
        //false：失败
        echo '1';
    }

    //3.关闭连接
    $conn->close();//关闭数据库
?>